//
//  ClassificationTableViewCell.m
//  110
//
//  Created by 沈鑫 on 16/4/13.
//  Copyright © 2016年 乔砥. All rights reserved.
//

#import "ClassificationTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation ClassificationTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        _commodityImageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, (KWIDTH - 40) / 2, 80)];
        _commodityImageView1.userInteractionEnabled = YES;
        [self.contentView addSubview:_commodityImageView1];
        _titleLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(10, 95, (KWIDTH - 40) / 2, 20)];
        [self.contentView addSubview:_titleLabel1];
        
        _button = [UIButton buttonWithType:UIButtonTypeCustom];
        _button.frame = CGRectMake(0, 0, (KWIDTH - 40) / 2, 80);
        
        [self.commodityImageView1 addSubview:_button];
        
        _priceLabel1 = [[UILabel alloc]initWithFrame:CGRectMake(10, 130, 100, 20)];
        _priceLabel1.textColor = [UIColor redColor];
        [self.contentView addSubview:_priceLabel1];
        
        // =======================================
        _commodityImageView2 = [[UIImageView alloc]initWithFrame:CGRectMake(30 + (KWIDTH - 40) / 2, 10, (KWIDTH - 40) / 2, 80)];
        _commodityImageView2.userInteractionEnabled = YES;
        [self.contentView addSubview:_commodityImageView2];
        _titleLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(30 + (KWIDTH - 40) / 2, 95, (KWIDTH - 40) / 2, 20)];
        [self.contentView addSubview:_titleLabel2];
        
        _button1 = [UIButton buttonWithType:UIButtonTypeCustom];
        _button1.frame = CGRectMake(0, 0, (KWIDTH - 40) / 2, 80);
        
        [self.commodityImageView2 addSubview:_button1];
        
        _priceLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(30 + (KWIDTH - 40) / 2, 130, 100, 20)];
        _priceLabel2.textColor = [UIColor redColor];
        [self.contentView addSubview:_priceLabel2];
        
        UIView *lView = [[UIView alloc]initWithFrame:CGRectMake(20 + (KWIDTH - 40) / 2, 0, 0.5, 159)];
        lView.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:lView];
        
        UIView *lViewSahang = [[UIView alloc]initWithFrame:CGRectMake(0, 1, KWIDTH, 0.5)];
        lViewSahang.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:lViewSahang];
        
        UIView *lViewSahang1 = [[UIView alloc]initWithFrame:CGRectMake(0, 159, KWIDTH, 0.5)];
        lViewSahang1.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:lViewSahang1];
    }
    return self;
}

- (void)getModel:(ClassificationModel *)model1 modle2:(ClassificationModel *)model2
{
//    [_commodityImageView1 sd_setImageWithURL:[NSURL URLWithString:model1.titleimg]];
    [_commodityImageView1 sd_setImageWithURL:[NSURL URLWithString:model1.titleimg] placeholderImage:[UIImage imageNamed:@"zanwutupian"]];
    _titleLabel1.text = model1.namecn;
    
    _priceLabel1.text = [NSString stringWithFormat:@"￥%ld",model1.avgprice];
    if (model1.avgprice == 0.00)
    {
        _priceLabel1.text = @"暂无定价";
    }
    
    
    if (model2 == nil)
    {
        return;
    }
//    [_commodityImageView2 sd_setImageWithURL:[NSURL URLWithString:model2.titleimg]];
    [_commodityImageView2 sd_setImageWithURL:[NSURL URLWithString:model2.titleimg] placeholderImage:[UIImage imageNamed:@"zanwutupian"]];
    _titleLabel2.text = model2.namecn;
    _priceLabel2.text = [NSString stringWithFormat:@"￥%ld",model2.avgprice];
    
    if (model2.avgprice == 0.00)
    {
        _priceLabel2.text = @"暂无定价";
    }


}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
